package dame;

import java.util.PriorityQueue;

public class Test {
    public int[] smallestk(int[] array ,int k){  //获取前K个中最小的元素
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        for (int i=0;i<array.length;i++){
            queue.offer(array[i]);
        }
        int[] ret = new int[k];
        for (int j=0;j<k;j++){
            ret[j] = queue.poll();
        }
        return ret;
    }
    public static void main(String[] args) {
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        TestHeap testHeap = new TestHeap();
        testHeap.initElem(array);
        testHeap.createTestHeap();
    }
}
